package com.example.day04_fragment;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //创建fragment管理器对象
        FragmentManager manager = getSupportFragmentManager();
        //开始事务
        FragmentTransaction transaction = manager.beginTransaction();
        //添加fragment
        transaction.add(R.id.frame,new MyFragment());
        //提交
        transaction.commit();


    }
}